home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWGDev.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  7.8 KB  |  284 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWGDev.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWGDEV_H
  11. #define FWGDEV_H
  12.  
  13. #ifndef FWGRDEF_H
  14. #include "FWGrDef.h"
  15. #endif
  16.  
  17. #ifndef FWGCONST_H
  18. #include "FWGConst.h"
  19. #endif
  20.  
  21. #ifndef FWPOINT_H
  22. #include "FWPoint.h"
  23. #endif
  24.  
  25. #ifndef FWCOLOR_H
  26. #include "FWColor.h"
  27. #endif
  28.  
  29. #if defined(FW_BUILD_WIN) && !defined(FWGDIOBJ_H)
  30. #include "FWGDIObj.h"
  31. #endif
  32.  
  33. #ifdef SelectFont
  34. #undef SelectFont    // Macro in Windowsx.h
  35. #endif
  36.  
  37. // ----- Foundation Includes -----
  38.  
  39. #ifndef FWREFCNT_H
  40. #include "FWRefCnt.h"
  41. #endif
  42.  
  43. // ----- OpenDoc Includes -----
  44.  
  45. #ifndef SOM_ODCanvas_xh
  46. #include <Canvas.xh>
  47. #endif
  48.  
  49. #ifndef SOM_ODTransform_xh
  50. #include <Trnsform.xh>
  51. #endif
  52.  
  53. #if FW_LIB_EXPORT_PRAGMAS
  54. #pragma lib_export on
  55. #endif
  56.  
  57. //========================================================================================
  58. //    Forward Declarations
  59. //========================================================================================
  60.  
  61. class FW_CLASS_ATTR ODShape;
  62. class FW_CLASS_ATTR FW_PInk;
  63. class FW_CLASS_ATTR FW_PStyle;
  64. class FW_CLASS_ATTR FW_PFont;
  65. class FW_CLASS_ATTR FW_CPoint;
  66. class FW_CLASS_ATTR FW_CRect;
  67. class FW_CLASS_ATTR FW_CGraphicContext;
  68.  
  69. struct FW_CLASS_ATTR FW_SPlatformRect;
  70. struct FW_CLASS_ATTR FW_SPlatformPoint;
  71.  
  72. //========================================================================================
  73. //    class FW_CGraphicDevice
  74. //========================================================================================
  75.  
  76. class FW_CLASS_ATTR FW_CGraphicDevice : public FW_MRefCount
  77. {
  78. //---------------------------------------------------------------------------------------
  79. //    Constructor/Destructor
  80. //
  81. public:
  82.                             FW_CGraphicDevice(Environment *ev, ODCanvas* odCanvas);
  83.                             FW_CGraphicDevice(Environment *ev, ODPlatformCanvas platformCanvas);
  84.     
  85.     virtual                 ~FW_CGraphicDevice();
  86.  
  87. //---------------------------------------------------------------------------------------
  88. //    API
  89. //
  90. public:
  91.     ODPlatformCanvas        GetPlatformCanvas() const;
  92.     operator                 ODPlatformCanvas() const;
  93.  
  94.     ODCanvas*                 GetODCanvas() const;
  95.  
  96.     FW_SDeviceState*        OpenDevice(Environment *ev, FW_CGraphicContext* context);
  97.     void                     CloseDevice(Environment *ev, FW_SDeviceState* deviceState);
  98.     
  99.     ODRgnHandle             GetClip() const;                                            // return a copy
  100.     void                    GetClipRect(FW_SPlatformRect& clipRect) const;
  101.  
  102.     void                     SetClip(ODRgnHandle clipRegion);                            // Use a copy
  103.     void                    SetClipRect(const FW_SPlatformRect& clipRect);
  104.     void                    IntersectClipRect(const FW_SPlatformRect& clipRect);
  105.  
  106.     void                    SetOrigin(FW_SPlatformPoint origin);
  107.     
  108.     FW_SDeviceState*        GetState();
  109.     
  110.     FW_SSuspendResumeState*    Suspend();
  111.     void                    Resume(FW_SSuspendResumeState *suspendResumeState);
  112.                                                         
  113.     void                    CanvasChanged(Environment *ev, ODCanvas* odCanvas);
  114.     void                    MappingChanged();
  115.     
  116.     // ----- Return the resolution in dpi -----
  117.     FW_CPoint                GetResolution(Environment *ev) const;
  118.     void                    SetResolution(const FW_CPoint& resolution);
  119.     
  120. private:
  121.     void                    UpdateOriginForContext();
  122.                                      
  123. //----------------------------------------------------------------------------------------
  124. //    Data Members
  125. //
  126. protected:
  127.     ODCanvas*                 fODCanvas;            // Might be NULL
  128.     ODPlatformCanvas         fPlatformCanvas;
  129.     
  130.     short                    fOpenDeviceCount;
  131.     
  132.     FW_CPoint                 fResolution;
  133.  
  134.     FW_Boolean                fSuspended;
  135.     
  136.     FW_CGraphicContext*        fContext;
  137.     
  138.     Environment*            fEV;
  139.  
  140. //----------------------------------------------------------------------------------------
  141. //    Platform Specific API
  142. //
  143. #ifdef FW_BUILD_WIN
  144. public:
  145.     void                    SelectFont(const FW_PFont& font, FW_Boolean scale);
  146.  
  147.     FW_Boolean                IsMetaFileCanvas() const;
  148.  
  149.     // ----- Settings -----    
  150.     void                    SelectInkAndFont(const FW_PInk& ink, 
  151.                                             const FW_PFont& font);
  152.     FW_Boolean                SelectInkAndStyle(const FW_PInk& ink, 
  153.                                             const FW_PStyle& style,
  154.                                             FW_EShapeCategories shapeType, 
  155.                                             FW_ERenderVerbs renderVerb);
  156.                                             
  157.     void                    SetTextColor(COLORREF textColor);    
  158.     void                    SetBkColor(COLORREF bkColor);
  159.     
  160. protected:
  161.     // ----- We don't bother doing any caching for those, they should be pretty fast -----
  162.     void                    SetDrawingMode(int drawingMode)
  163.                                 {::SetROP2(fPlatformCanvas, drawingMode);}
  164.     void                    SetBkMode(int bkMode)
  165.                                 {::SetBkMode(fPlatformCanvas, bkMode);}
  166. #endif
  167. #ifdef FW_BUILD_MAC                                    
  168. public:
  169.     // ----- Settings -----
  170.     void                    SelectInk(const FW_PInk& ink, 
  171.                                 FW_EShapeCategories shapeCategory, 
  172.                                 FW_ERenderVerbs renderVerb);
  173.     FW_Boolean                SelectStyle(const FW_PStyle& style, 
  174.                                 FW_TransferModes transferMode);
  175.     void                    SelectFont(const FW_PFont& font, 
  176.                                 FW_Boolean scale);
  177.  
  178.     void                    SetInGrafPort();
  179.     void                    ResetSettings();
  180.     
  181.     // Values for fChangeFlag
  182.     enum
  183.     {
  184.         FW_kForeColorChanged     =    0x0001,
  185.         FW_kBackColorChanged    =    0x0002,
  186.         FW_kHiliteColorChanged    =    0x0004,
  187.         FW_kPatternChanged        =    0x0008
  188.     };
  189.  
  190.     void                    SetForeColor(const FW_CColor& foreColor)
  191.                                 {fForeColor = foreColor; fChangeFlag |= FW_kForeColorChanged;}
  192.     void                    SetBackColor(const FW_CColor& backColor)
  193.                                 {fBackColor = backColor; fChangeFlag |= FW_kBackColorChanged;}
  194.     void                    SetHiliteColor(const FW_CColor& hiliteColor)
  195.                                 {fHiliteColor = hiliteColor; fChangeFlag |= FW_kHiliteColorChanged;}
  196.     void                    SetPattern(const FW_PPattern& pattern);
  197.     void                    SetPenSize(short hPenSize, short vPenSize)
  198.                                 {fHPenSize = hPenSize; fVPenSize = vPenSize;}
  199.     void                    SetFontID(short fontID)
  200.                                 {fFontID = fontID;}
  201.     void                    SetFontSize(short fontSize)
  202.                                 {fFontSize = fontSize;}
  203.     void                    SetFontStyle(Style fontStyle)
  204.                                 {fFontStyle = fontStyle;}
  205.     void                    SetPenMode(short penMode)
  206.                                 {fPenMode = penMode;}
  207.     void                    SetTextMode(short textMode)
  208.                                 {fTextMode = textMode;}
  209.     
  210.     static void             SetHiliteMode();
  211.  
  212. private:                            
  213.     void                    MacBeginPostScriptClip(RgnHandle rgn);
  214.     void                    MacEndPostScriptClip();
  215. #endif
  216.  
  217. //----------------------------------------------------------------------------------------
  218. //    Platform Specific Data Members
  219. //
  220. #ifdef FW_BUILD_WIN
  221. public:
  222.     // ----- Settings -----
  223.     COLORREF                fTextColor;
  224.     COLORREF                fBkColor;
  225.     FW_SPlatformPoint        fPenSize;    // Used for frame with brush
  226.  
  227.     // ----- Brush/Pen/Font -----
  228.     FW_CPrivGDIPen            fGDIPen;
  229.     FW_CPrivGDIBrush        fGDIBrush;
  230.     FW_CPrivGDIFont            fGDIFont;
  231. #endif
  232. #ifdef FW_BUILD_MAC
  233. public:
  234.     // ----- Device Settings -----
  235.     FW_CColor                 fForeColor;
  236.     FW_CColor                fBackColor;
  237.     FW_CColor                fHiliteColor;
  238.     FW_PPattern                fPattern;
  239.     short                    fHPenSize;
  240.     short                    fVPenSize;
  241.     short                    fFontID;
  242.     short                    fFontSize;
  243.     Style                    fFontStyle;
  244.     short                    fPenMode;
  245.     short                    fTextMode;
  246.  
  247. private:
  248.     unsigned short            fChangeFlag;
  249.  
  250.     // ----- PostScript clipping
  251.     FW_Boolean                fMacPostScriptClip;
  252. #endif
  253. };
  254.  
  255. //---------------------------------------------------------------------------------------
  256. //    FW_CGraphicDevice::GetODCanvas
  257. //---------------------------------------------------------------------------------------
  258. inline ODCanvas* FW_CGraphicDevice::GetODCanvas() const
  259. {
  260.     return fODCanvas;
  261. }
  262.  
  263. //---------------------------------------------------------------------------------------
  264. //    FW_CGraphicDevice::GetPlatformCanvas
  265. //---------------------------------------------------------------------------------------
  266. inline ODPlatformCanvas FW_CGraphicDevice::GetPlatformCanvas() const
  267. {
  268.     return fPlatformCanvas;
  269. }
  270.  
  271. //---------------------------------------------------------------------------------------
  272. //    FW_CGraphicDevice::operator ODPlatformCanvas
  273. //---------------------------------------------------------------------------------------
  274. inline FW_CGraphicDevice::operator ODPlatformCanvas() const
  275. {
  276.     return fPlatformCanvas;
  277. }
  278.  
  279. #if FW_LIB_EXPORT_PRAGMAS
  280. #pragma lib_export off
  281. #endif
  282.                                     
  283. #endif
  284.